<template>
    <div class="body">

        <div class="xiaobao">
            {{StoreNam}}
        </div>
        <div class="one">
            {{packaged}}
        </div>

        <div class="left"><span> 随时退 | 免预约 | 过期自动退 </span> </div>
        <div class="right">
            <i>半年销量 {{sales}}</i>
        </div>

        <ul>
            <li v-for="item in packageList">
                <img :src='item.img' alt=""> 
                <span>{{item.productName}}</span>
                <br>
                <i>￥{{item.price}}</i>
            </li>
        </ul>

        <div class="two">
            <ol>
                <li><strong>小吃</strong></li>
                <li><span>草莓奶油甜甜圈</span><i>¥8</i></li>
                <li><span>晴天芒果班戟</span><i>¥15</i></li>
            </ol>
        </div>

        <div class="three">
            <strong>备注</strong>
            <span>免费提供纸巾</span>
        </div>

        <div class="prompt">
            <h1>温馨提示</h1>
            <h2>有效期：</h2>
            <h3>{{days}}</h3>
            <h5>使用时间：</h5>
            <h6>{{times}} </h6>
            <strong>使用规则：</strong>
            <span>无需预约，消费高峰时刻能需要等位</span>
            <span>每张券建议多人使用</span>
        </div>

        <div class="more">
            <span> 查看更多</span>
        </div>

        <van-submit-bar :price="and*100" button-text="立刻抢购" @submit="onSubmit" button-color="rgba(255, 141, 26, 1)" >
          
            <template #tip >
                最高门市价 ¥{{and}}    <span @click="onClickLink"></span>
            </template>
        </van-submit-bar>
    </div>

</template>

<script setup>
import { onMounted ,ref} from 'vue'
import {getPackage} from '@/api/api'
import router from "@/router"

const packageList=ref([])
const packaged=ref(null)
const StoreNam=ref(null)
const times=ref(null)
const days=ref(null)
const sales=ref(null)
const and=ref(null)

onMounted(async ()=>{
    let uid=localStorage.getItem('uId')
    let packageId=localStorage.getItem('packageId')
let {data}=await getPackage({uid,packageId})


packageList.value=data[0].info.filter((item,index)=>index<3)
packaged.value=data[0].PackageName
StoreNam.value=data[0].storename2
times.value=data[0].time
days.value=data[0].Valid
sales.value=data[0].salesVolume
and.value=packageList.value.reduce((prev,item)=>{
    return prev+item.price
},0)
})

  const ids = ref()
  onMounted(()=>{
      ids.value = localStorage.getItem('packageId')
  })

 const onSubmit = () => {
    console.log(ids);
     router.push({name:'snapped1',query:{id:ids.value}})
    //  router.push({name:'snapped1',query:{id:1}})
 }
//  const onSubmit = () => {
   
//  }
//  const onClickLink = () => {
    
//  }
</script>

<style lang="scss" scoped>
.body {
    height: 1000px;
    overflow-y: scroll;
    box-sizing: border-box;
    width: 100%;
}

.tab {
    width: 100%;
    height: 120px;
    background-color: red;

}

.xiaobao {
    width: 439px;
    height: 48px;
    left: 16px;
    top: 125px;
    color: rgba(51, 51, 51, 1);
    font-size: 28px;
    line-height: 150%;
    text-align: left;
    margin-top: 20px;
    padding: 20px;
    box-sizing: border-box;
}

.one {
    width: 250px;
    height: 60px;
    left: 16px;
    top: 149px;
    color: rgba(56, 56, 56, 1);
    font-size: 40px;
    line-height: 150%;
    text-align: left;
    font-weight: bold;
    padding: 20px;

}

.left {
    float: left;
}

.left span {

    padding: 20px;
    margin-right: 20px;
    width: 656px;
    height: 48px;
    color: rgba(166, 166, 166, 1);
    font-size: 22px;
    line-height: 150%;

}

.right {
    float: right;
}

.right i {
    padding: 20px;
    margin-left: 20px;
    font-size: 22px;
    line-height: 150%;
    color: rgba(166, 166, 166, 1);
}

ul {
    width: 600px;
    height: 314px;
    display: flex;
    padding: 20px;
}

ul li {
    width: 200px;
    height: 200px;
    margin: 0 19px 0 20px;
    height: 314px;
}

ul li span {
    width: 200px;
    height: 48px;
    left: 17px;
    top: 187px;
    color: rgba(80, 80, 80, 1);
    font-size: 22px;
    line-height: 150%;
    text-align: left;
}

ul li i {
    width: 200px;
    height: 48px;
    left: 16px;
    top: 337px;
    color: rgba(80, 80, 80, 1);
    font-size: 22px;
    line-height: 150%;
    text-align: left;
}

ul li img {
    width: 200px;
    height: 200px;
    left: 17px;
    top: 211px;
    background-color: rgba(238, 238, 238, 1);

}

.two {
    width: 100%px;
    height: 144px;
    padding: 20px;
    box-sizing: border-box;
}

.two li strong {
    width: 58px;
    height: 48px;
    left: 16px;
    top: 368px;
    color: rgba(56, 56, 56, 1);
    font-size: 28px;
    line-height: 150%;
    font-weight: bold;
}

.two ol li {
    width: 100% !important;
    height: 28px;
    width: 244px;
    height: 48px;
    left: 22px;
    top: 441px;
    color: rgba(56, 56, 56, 1);
    font-size: 22px;
    line-height: 150%;
}

.two ol li span {
    float: left;
}

.two>ol>li>i {
    float: right;
}

.three {
    width: 100%;
    height: 144px;
    padding: 20px;
    box-sizing: border-box;

}

.three span {
    display: block;
    width: 244px;
    height: 48px;
    left: 22px;
    top: 480px;
    color: rgba(56, 56, 56, 1);
    font-size: 22px;
    line-height: 150%;
}

.three strong {
    width: 58px;
    height: 48px;
    left: 16px;
    top: 456px;
    color: rgba(56, 56, 56, 1);
    font-size: 28px;
    line-height: 150%;
    font-weight: bold;
}

.prompt {
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

.prompt h1 {
    width: 160px;
    height: 60px;
    left: 16px;
    top: 339px;
    color: rgba(56, 56, 56, 1);
    font-size: 40px;
    text-align: left;
    font-weight: bold;
}

.prompt h2 {
    width: 144px;
    // height: 48px;
    left: 16px;
    top: 369px;
    color: rgba(56, 56, 56, 1);
    font-size: 28px;
    font-weight: bold;
}

.prompt h3 {
    width: 644px;
    height: 48px;
    left: 22px;
    top: 393px;
    color: rgba(56, 56, 56, 1);
    font-size: 22px;

}

.prompt h4 {
    width: 144px;
    height: 48px;
    left: 16px;
    top: 417px;
    color: rgba(56, 56, 56, 1);
    font-size: 28px;
    font-weight: bold;
}

.prompt h5 {
    width: 644px;
    height: 48px;
    left: 22px;
    top: 441px;
    color: rgba(56, 56, 56, 1);
    font-size: 22px;
}

.prompt h6 {
    width: 644px;
    height: 48px;
    left: 22px;
    top: 441px;
    color: rgba(56, 56, 56, 1);
    font-size: 22px;
}

.prompt strong {
    width: 144px;
    height: 48px;
    left: 16px;
    top: 460px;
    color: rgba(56, 56, 56, 1);
    font-size: 28px;
    line-height: 150%;
    font-weight: bold;
}

.prompt span {
    width: 644px;
    height: 48px;
    left: 22px;
    top: 484px;
    color: rgba(56, 56, 56, 1);
    font-size: 22px;
    line-height: 150%;
    display: block;
}

.more {
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

.more span {
    width: 112px;
    height: 42px;
    left: 152px;
    top: 550px;
    color: rgba(255, 141, 26, 1);
    font-size: 28px;
    line-height: 150%;
    display: block;
    margin: 0 auto;
}

</style>